﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BG.DAL.Model;
using BG.DAL.Context;
using System.Data;

namespace BG.DAL.SQLDAL
{
    public class TicketStaffManager
    {

        public static TicketStaff GetById(Guid id)
        {
            using (DataContext db = new DataContext())
            {
                TicketStaff Model = db.TicketStaffs.Find(id);
                return Model;
            }
        }

        public static List<TicketStaff> GetAll()
        {
            using (DataContext db = new DataContext())
            {
                var i = db.TicketStaffs.ToList();
                return i;
            }
        }

        public static List<TicketStaff> GetByFilter(string text)
        {
            using (DataContext db = new DataContext())
            {
                return db.TicketStaffs.Where(m => m.sStaffName.Equals(text)).ToList();
            }
        }

        public static void Create(TicketStaff model)
        {
            using (DataContext db = new DataContext())
            {
                db.TicketStaffs.Add(model);
                db.SaveChanges();
            }
        }

        public static void Edit(TicketStaff model)
        {
            using (DataContext db = new DataContext())
            {
                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
            }
        }

        public static void Delete(Guid id)
        {
            using (DataContext db = new DataContext())
            {
                TicketStaff model = db.TicketStaffs.Find(id);
                db.TicketStaffs.Remove(model);
                db.SaveChanges();

            }
        }
    }
}
